--
-- Created by IntelliJ IDEA.
-- User: xueal
-- Date: 2017/9/11
-- Time: 21:45
-- To change this template use File | Settings | File Templates.
--
local tb1 = {a = 1, b = 2}
local tb2 = {a = 1, b = 2}
local tb3 = tb1

if tb1 == tb2 then
     print("tb1 == tb2")
else
     print("tb1 ~= tb2")
end

tb3.a = 3
print(tb1.a)

print("--------------------------------------")

--local Account = {balance = 0}
--function Account.withDraw(self, v)
--     self.balance = self.balance - v
--end
--
--local a = Account
--Account = nil
--a.withDraw(a, 100)
--print(a.balance)

Account = {balance = 0}
function Account:withDraw(v) -- 注意这里的冒号":"
     self.balance = self.balance - v
end

a = Account
Account = nil
a:withDraw(100) -- 注意这里的调用时，也需要冒号":"
print(a.balance)
